package com.tqjc.system.C24012.core.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tqjc.system.C24012.common.constant.SystemConstants;
import com.tqjc.system.C24012.common.entity.SysSteelPartEntity;
import com.tqjc.system.C24012.core.service.SysAreaInfoService;
import com.tqjc.system.C24012.core.service.SysSteelPartService;
import com.tqjc.system.C24012.core.wrapper.SteelPartWrapper;
import com.tqjc.system.common.controller.BaseController;
import com.tqjc.system.core.model.AjaxJson;
import com.tqjc.system.core.util.ResponseUtil;
import com.tqjc.system.system.wrapper.DeptWrapper;
import com.tqjc.system.system.wrapper.MenuWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author: 86195
 * @CreateTime: 2024-06-27  15:41
 * @Description: 库区控制器
 * @Version: 1.0
 */
@Slf4j
@Controller
@RequestMapping("sys/area")
public class AreaController extends BaseController {

    @Autowired
    private SysAreaInfoService areaInfoService;

    @Autowired
    private SysSteelPartService steelPartService;


    /**
     * 首页
     *
     * @return
     */
    @RequestMapping("/display")
    public String index() {
        return "C24012/area/areaDisplay.html";
    }


    @RequestMapping("/queryAreaInfo")
    @ResponseBody
    public void queryAreaInfo(String areaId, HttpServletRequest request, HttpServletResponse response) {

        LambdaQueryWrapper<SysSteelPartEntity> wrapper = new LambdaQueryWrapper<SysSteelPartEntity>().eq(SysSteelPartEntity::getAreaId, areaId)
                .eq(SysSteelPartEntity::getStatus, SystemConstants.STEEL_PART_IN).orderByDesc(SysSteelPartEntity::getLayer);
        List<SysSteelPartEntity> lstResult = steelPartService.list(wrapper);
        //结果处理,直接写到客户端
        ResponseUtil.write(response, new SteelPartWrapper(lstResult).wrap());

    }
}
